package demo.db;

import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by hdt3213 on 17/8/18.
 */

@Mapper
interface UserMapper {

	@Insert("INSERT INTO `User` (`username`, `password`) VALUES (#{username}, #{password});")
	int insert(User user);

	@Delete("DELETE FROM `User` WHERE `id`=#{id}")
	int delete(User user);

	@Update("UPDATE `User` SET `username`=#{username}, `passsword`=#{password} where `id`=#{id}")
	int update(User user);

	@Select("SELET * FROM `User` WHERE `id`=#{id}")
	List<User> find(@Param("id") int id);

	@Select("SELET count(*) FROM `User` WHERE `id`=#{id}")
	int exists(@Param("id") int id);
}
